/**
 */
package ConnectorGenerator.ElementArchitecture.impl;

import ConnectorGenerator.Auxiliary.impl.FirstClassEntityImpl;

import ConnectorGenerator.ElementArchitecture.Attribute;
import ConnectorGenerator.ElementArchitecture.ElementArchitecture;
import ConnectorGenerator.ElementArchitecture.ElementArchitecturePackage;
import ConnectorGenerator.ElementArchitecture.ElementType;
import ConnectorGenerator.ElementArchitecture.LocalBinding;
import ConnectorGenerator.ElementArchitecture.RealizedFeature;
import ConnectorGenerator.ElementArchitecture.RemoteBinding;
import ConnectorGenerator.ElementArchitecture.SignatureConstraint;
import ConnectorGenerator.ElementArchitecture.SubElement;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Element Architecture</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getType <em>Type</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getName <em>Name</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getCodeTemplate <em>Code Template</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getSubElements <em>Sub Elements</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getLocalBindings <em>Local Bindings</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getFeatures <em>Features</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getSignatureConstraints <em>Signature Constraints</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getAttributes <em>Attributes</em>}</li>
 *   <li>{@link ConnectorGenerator.ElementArchitecture.impl.ElementArchitectureImpl#getRemoteBindings <em>Remote Bindings</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ElementArchitectureImpl extends FirstClassEntityImpl implements ElementArchitecture {
	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected ElementType type;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getCodeTemplate() <em>Code Template</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCodeTemplate()
	 * @generated
	 * @ordered
	 */
	protected static final String CODE_TEMPLATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getCodeTemplate() <em>Code Template</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCodeTemplate()
	 * @generated
	 * @ordered
	 */
	protected String codeTemplate = CODE_TEMPLATE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getSubElements() <em>Sub Elements</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSubElements()
	 * @generated
	 * @ordered
	 */
	protected EList<SubElement> subElements;

	/**
	 * The cached value of the '{@link #getLocalBindings() <em>Local Bindings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLocalBindings()
	 * @generated
	 * @ordered
	 */
	protected EList<LocalBinding> localBindings;

	/**
	 * The cached value of the '{@link #getFeatures() <em>Features</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFeatures()
	 * @generated
	 * @ordered
	 */
	protected EList<RealizedFeature> features;

	/**
	 * The cached value of the '{@link #getSignatureConstraints() <em>Signature Constraints</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSignatureConstraints()
	 * @generated
	 * @ordered
	 */
	protected EList<SignatureConstraint> signatureConstraints;

	/**
	 * The cached value of the '{@link #getAttributes() <em>Attributes</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAttributes()
	 * @generated
	 * @ordered
	 */
	protected EList<Attribute> attributes;

	/**
	 * The cached value of the '{@link #getRemoteBindings() <em>Remote Bindings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRemoteBindings()
	 * @generated
	 * @ordered
	 */
	protected EList<RemoteBinding> remoteBindings;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ElementArchitectureImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ElementArchitecturePackage.Literals.ELEMENT_ARCHITECTURE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ElementType getType() {
		if (type != null && type.eIsProxy()) {
			InternalEObject oldType = (InternalEObject)type;
			type = (ElementType)eResolveProxy(oldType);
			if (type != oldType) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__TYPE, oldType, type));
			}
		}
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ElementType basicGetType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(ElementType newType) {
		ElementType oldType = type;
		type = newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getCodeTemplate() {
		return codeTemplate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCodeTemplate(String newCodeTemplate) {
		String oldCodeTemplate = codeTemplate;
		codeTemplate = newCodeTemplate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__CODE_TEMPLATE, oldCodeTemplate, codeTemplate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SubElement> getSubElements() {
		if (subElements == null) {
			subElements = new EObjectContainmentEList<SubElement>(SubElement.class, this, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SUB_ELEMENTS);
		}
		return subElements;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<LocalBinding> getLocalBindings() {
		if (localBindings == null) {
			localBindings = new EObjectContainmentEList<LocalBinding>(LocalBinding.class, this, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__LOCAL_BINDINGS);
		}
		return localBindings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RealizedFeature> getFeatures() {
		if (features == null) {
			features = new EObjectContainmentEList<RealizedFeature>(RealizedFeature.class, this, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__FEATURES);
		}
		return features;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SignatureConstraint> getSignatureConstraints() {
		if (signatureConstraints == null) {
			signatureConstraints = new EObjectContainmentEList<SignatureConstraint>(SignatureConstraint.class, this, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SIGNATURE_CONSTRAINTS);
		}
		return signatureConstraints;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Attribute> getAttributes() {
		if (attributes == null) {
			attributes = new EObjectContainmentEList<Attribute>(Attribute.class, this, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__ATTRIBUTES);
		}
		return attributes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RemoteBinding> getRemoteBindings() {
		if (remoteBindings == null) {
			remoteBindings = new EObjectContainmentEList<RemoteBinding>(RemoteBinding.class, this, ElementArchitecturePackage.ELEMENT_ARCHITECTURE__REMOTE_BINDINGS);
		}
		return remoteBindings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SUB_ELEMENTS:
				return ((InternalEList<?>)getSubElements()).basicRemove(otherEnd, msgs);
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__LOCAL_BINDINGS:
				return ((InternalEList<?>)getLocalBindings()).basicRemove(otherEnd, msgs);
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__FEATURES:
				return ((InternalEList<?>)getFeatures()).basicRemove(otherEnd, msgs);
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SIGNATURE_CONSTRAINTS:
				return ((InternalEList<?>)getSignatureConstraints()).basicRemove(otherEnd, msgs);
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__ATTRIBUTES:
				return ((InternalEList<?>)getAttributes()).basicRemove(otherEnd, msgs);
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__REMOTE_BINDINGS:
				return ((InternalEList<?>)getRemoteBindings()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__TYPE:
				if (resolve) return getType();
				return basicGetType();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__NAME:
				return getName();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__CODE_TEMPLATE:
				return getCodeTemplate();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SUB_ELEMENTS:
				return getSubElements();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__LOCAL_BINDINGS:
				return getLocalBindings();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__FEATURES:
				return getFeatures();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SIGNATURE_CONSTRAINTS:
				return getSignatureConstraints();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__ATTRIBUTES:
				return getAttributes();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__REMOTE_BINDINGS:
				return getRemoteBindings();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__TYPE:
				setType((ElementType)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__NAME:
				setName((String)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__CODE_TEMPLATE:
				setCodeTemplate((String)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SUB_ELEMENTS:
				getSubElements().clear();
				getSubElements().addAll((Collection<? extends SubElement>)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__LOCAL_BINDINGS:
				getLocalBindings().clear();
				getLocalBindings().addAll((Collection<? extends LocalBinding>)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__FEATURES:
				getFeatures().clear();
				getFeatures().addAll((Collection<? extends RealizedFeature>)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SIGNATURE_CONSTRAINTS:
				getSignatureConstraints().clear();
				getSignatureConstraints().addAll((Collection<? extends SignatureConstraint>)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__ATTRIBUTES:
				getAttributes().clear();
				getAttributes().addAll((Collection<? extends Attribute>)newValue);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__REMOTE_BINDINGS:
				getRemoteBindings().clear();
				getRemoteBindings().addAll((Collection<? extends RemoteBinding>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__TYPE:
				setType((ElementType)null);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__CODE_TEMPLATE:
				setCodeTemplate(CODE_TEMPLATE_EDEFAULT);
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SUB_ELEMENTS:
				getSubElements().clear();
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__LOCAL_BINDINGS:
				getLocalBindings().clear();
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__FEATURES:
				getFeatures().clear();
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SIGNATURE_CONSTRAINTS:
				getSignatureConstraints().clear();
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__ATTRIBUTES:
				getAttributes().clear();
				return;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__REMOTE_BINDINGS:
				getRemoteBindings().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__TYPE:
				return type != null;
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__CODE_TEMPLATE:
				return CODE_TEMPLATE_EDEFAULT == null ? codeTemplate != null : !CODE_TEMPLATE_EDEFAULT.equals(codeTemplate);
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SUB_ELEMENTS:
				return subElements != null && !subElements.isEmpty();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__LOCAL_BINDINGS:
				return localBindings != null && !localBindings.isEmpty();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__FEATURES:
				return features != null && !features.isEmpty();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__SIGNATURE_CONSTRAINTS:
				return signatureConstraints != null && !signatureConstraints.isEmpty();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__ATTRIBUTES:
				return attributes != null && !attributes.isEmpty();
			case ElementArchitecturePackage.ELEMENT_ARCHITECTURE__REMOTE_BINDINGS:
				return remoteBindings != null && !remoteBindings.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", codeTemplate: ");
		result.append(codeTemplate);
		result.append(')');
		return result.toString();
	}

} //ElementArchitectureImpl
